<template>
	<view class="tranfer_clue">
		<view class="fllow_form">
			<view style="color: #333;font-size: 32rpx;"><text>*</text>接收对象</view>
			<picker @change="changeStaff" :range="staffList" :value="staffIndex" :range-key="'name'">
				<view class="form_right">
					<view>{{staffname ? staffname : '点击选择'}}</view>
					<view class="iconfont icon-arrows_right"></view>
				</view>
			</picker>
		</view>
		<view id="btn" class="btn_g bg-blue button-hover round" @click="Totrans">
			保存
		</view>
	</view>
</template>

<script>
	import { netStaffList, netTransKehu } from '@/api/kehu.js'
	import { BASE_IMG_URL } from '@/util/api.js'
	export default {
		data() {
			return {
				id:'',   //客户id
				staff_id:'',    //员工id
				staffname:'',
				staffList:[],
				staffIndex:null
			}
		},
		onLoad(options) {
			this.id = options.id
			
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				netStaffList().then(res=>{
					this.staffList = res.data
				})
			},
			changeStaff(e) {
				this.staffIndex = e.detail.value
				this.staff_id = this.staffList[e.detail.value].id
				this.staffname = this.staffList[e.detail.value].name
			},
			Totrans() {
				if(!this.staff_id){
					uni.showToast({
						title:'请选择接受对象',
						icon:'none'
					})
					return
				}
				let params = {
					id:this.id,
					staff_id: this.staff_id
				}
				netTransKehu(params).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					setTimeout(()=>{
						uni.redirectTo({
							url:"/pagesA/crm/customerManagement/customerManagement"
						})
					},1000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
  .fllow_form {
		display: flex;
		justify-content: space-between;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		border-bottom: 1rpx solid #EAEAEA;
		padding: 0 30rpx 0 47rpx;
		margin: 30rpx 0;
		.form_right {
			display: flex;
			color: #999;
			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}
		}
		text {
			color: #f00;
			margin-left: 10rpx;
		}
	}
	.fllow_area {
				background-color: #fff;
				margin-bottom: 30rpx;
				padding-bottom: 30rpx;
				color: #999;
				.area_head {
					height: 100rpx;
					line-height: 100rpx;
					font-size: 32rpx;
					padding: 0 70rpx;
					text {
						color: #f00;
					}
				}
				textarea {
					width: 80%;
					height: 300rpx;
					padding: 30rpx;
					background: #f8f8f8;
					margin: 0 auto;
				}
			}
	#btn {
		font-size: 26rpx;
		color: #fff;
		text-align: center;
		line-height: 88rpx;
		width: 500rpx;
		height: 88rpx;
		background: #03AA96;
		border-radius: 29rpx;
	}
</style>
